package com.yotoodesign.dianba.fragment;


import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.yotoodesign.dianba.R;
import com.yotoodesign.dianba.bean.Ktv;
import com.yotoodesign.dianba.ui.DialogUtil;
import com.yotoodesign.dianba.ui.Share2Friends;


public class KtvDetailFragment extends BaseFragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.ktv_detail_framgment, container,false);
		TextView title = (TextView)view.findViewById(R.id.mainTitle);
		title.setText("KTV详情");
		
		ImageButton commonBack = (ImageButton)view.findViewById(R.id.commonBack);
		commonBack.setOnClickListener(new View.OnClickListener() {
			FragmentManager fm = getActivity().getSupportFragmentManager();
			@Override
			public void onClick(View v) {
				fm.popBackStack();
			}
		});
		Ktv ktv = (Ktv)this.getData();
		
		final TextView tvKtvName = (TextView)view.findViewById(R.id.tvKtvName);
		tvKtvName.setText(ktv.getName());
		
		final TextView tvAddress = (TextView)view.findViewById(R.id.tvAddress);
		tvAddress.setText(ktv.getAddr());
		
		final TextView tvPhone = (TextView)view.findViewById(R.id.tvPhone);
		tvPhone.setText(ktv.getPhoneNum());
		
		Button btnRecommend = (Button)view.findViewById(R.id.btnRecommend);
		btnRecommend.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				final Share2Friends dialog = DialogUtil.showSharedDialog(getActivity(),
						"分享到朋友圈", getView(), Gravity.BOTTOM);
				String info = tvKtvName.getText()+"还不错，在"+
						tvAddress.getText();
				if(tvPhone.getText()!=null && !tvPhone.getText().equals("")){
					info += "，电话："+tvPhone.getText();
				}
				
				info += "，有空和你的朋友们一起来嗨吧！";
				
				dialog.getEtMsg().setText(info);
				dialog.setOnOkClickListener(new Share2Friends.OkClickListener() {
					
					@Override
					public void onClick(View v) {
						
					}
				});
			}
		});
		
		return view;
	}

	@Override
	public void updateListView() {
		
	}

}
